#include "OscarProtData.h"
#include "wx/log.h"

namespace Impp
{
OscarProtData::OscarProtData() :
	userInfo()
{
}
OscarProtData::~OscarProtData()
{
}

UserInfo* OscarProtData::getUserInfo(){
	return &this->userInfo;
}

void OscarProtData::setUserInfo(UserInfo & info){
	if(this->userInfo.uin.IsEmpty()){
		this->userInfo.uin=info.uin;
	}
	if(this->userInfo.userClass==0){
		this->userInfo.userClass=info.userClass;
	}
	if(this->userInfo.ip ==0){
		this->userInfo.ip=info.ip;
	}
	this->userInfo.status = info.status;
	if(info.newCaps){
		this->userInfo.capabilities=info.capabilities;
	}
	if(this->userInfo.onlineTime==0){
		this->userInfo.onlineTime=info.onlineTime;
	}
	if(this->userInfo.onlineTimeData==0){
		this->userInfo.onlineTimeData=info.onlineTimeData;
	}
	if(this->userInfo.accountData==0){
		this->userInfo.accountData=info.accountData;
	}
	if(info.avatar.hasLng!=0){
		this->userInfo.avatar=info.avatar;
	}
	if(info.newIdleTime){
		this->userInfo.idleTime=info.idleTime;
	}
}

void OscarProtData::setAvatarInfo(AvatarInfo & info){
	this->userInfo.avatar=info;
}

void OscarProtData::goesOffline(){
	this->userInfo = UserInfo();
}

bool OscarProtData::getOnlineTime(wxDateTime & time){
	if(userInfo.onlineTime==0x00){
		return false;
	}
	time.Set((time_t)userInfo.onlineTime);
	return true;
}

bool OscarProtData::getIdleTime(wxDateTime & time){
	if(userInfo.idleTime==0x00){
		return false;
	}
	time.Set((time_t)userInfo.idleTime);
	return true;
}

bool OscarProtData::getIp(wxString & ip){
	if(userInfo.ip==0x00){
		return false;
	}
	ip = ipToString(userInfo.ip);
	return true;

}



}

